/*
 * Copyright © 2017 eqxiu.com 北京中网易企秀科技有限公司  All rights reserved.
 */
package cn.hermit.data.xml.validator;

import javax.xml.namespace.QName;

import cn.hermit.data.exception.ValidationException;

/**
 * 
 * XML Validator used for validate or adjust XML string in validator chain.
 * 
 * <p>
 * Sometimes, XML string need to be validated or the characters in 
 * XML string need to be adjusted for some use case.
 * It provides methods to validate tags and texts.
 * The <tt>Validator</tt> also provide a chain to for a serious of validation.
 * </p>
 * 
 * @see ValidatorChain
 * @author Jack Gao (Chinese name : GAO JIANGUO, Email : linux.gjg@gmail.com)
 * @date 19 Jun, 2014
 */
public interface Validator {

	/**
	 * Validate QName.
	 * 
	 * @param name
	 * 		The QName
	 * @return
	 * 		Adjusted QName
	 * @throws ValidationException
	 * 		If the validation failed, throw such exception
	 */
	QName validateQName(QName name) throws ValidationException;

	/**
	 * Validate Attribute value.
	 * 
	 * @param value
	 * 		The Attribute value
	 * @return
	 * 		Adjusted Attribute value
	 * @throws ValidationException
	 * 		If the validation failed, throw such exception
	 */
	Object validateValue(Object value) throws ValidationException;
	
	/**
	 * Validate Text string.
	 * 
	 * @param text
	 * 		The Text string
	 * @return
	 * 		Adjusted Text string
	 * @throws ValidationException
	 * 		If the validation failed, throw such exception
	 */
	Object validateText(Object text) throws ValidationException;
	
	/**
	 * Validate CDATA string.
	 * 
	 * @param cdata
	 * 		The CDATA string
	 * @return
	 * 		Adjusted CDATA string
	 * @throws ValidationException
	 * 		If the validation failed, throw such exception
	 */
	Object validateCData(Object cdata) throws ValidationException;

}